home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume6 / lj_filter < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  17.2 KB

  1. Subject:  v06i106:  Filter for HP Laserjet (lj_filter)
  2. Newsgroups: mod.sources
  3. Approved: rs@mirror.UUCP
  4.  
  5. Submitted by: cca!seismo!vsedev!ron (Ron Flax)
  6. Mod.sources: Volume 6, Issue 106
  7. Archive-name: lj_filter
  8.  
  9. [  I wrote the Makefile; also see my notes at the end of the README.
  10.    I don't have a LaserJet with which to test this program.  -r$ ]
  11.  
  12. #!/bin/sh
  13. # This is a shell archive.  Remove anything before this line,
  14. # then unpack it by saving it in a file and typing "sh file".
  15. # Wrapped by mirror!rs on Tue Aug 12 18:11:24 EDT 1986
  16. # Contents:  README laser.1 laser.c Makefile
  17.  
  18. echo x - README
  19. if test -f README ; then
  20.     echo README exists, putting output in $$README
  21.     OUT=$$README
  22. else
  23.     OUT=README
  24. fi
  25. sed 's/^XX//' > $OUT <<'@//E*O*F README//'
  26. XXThe file laser.c is the source to a program that will prepend the
  27. XXdesired setup codes for the Hewlet Packard LaserJet Printers.  It takes
  28. XXinto account such things as page orientation, line spacing, typeface
  29. XXselection, and most, if not all of the other print attributes available
  30. XXon the LaserJet.
  31.  
  32. XXTo compile simply type "make" then install the program and manpage in the
  33. XXappropriate directories for your system.  If anyone has any problems
  34. XXthey can reply to me at the address below.
  35.  
  36. XXThe only system dependencies that I can think of off hand are the fact
  37. XXthat the program uses 'getopt(3)' of which a PD version was posted a
  38. XXwhile back, and a selection of the print spooling program usually
  39. XX'lpr(1)' or on System V 'lp(1)'.  Either will work, there's even an
  40. XXoption to allow results to be send to the standard output.
  41.  
  42. XXMost of the typeface selections set default settings for other options
  43. XXin case you are lazy and only want to select a font by it's typeface
  44. XXname.  One other VERY IMPORTANT point I would like to make is that if
  45. XXyou don't have a particular font cartridge to use some of the features
  46. XXdescribed in the source, then you can't get there from here...
  47.  
  48. XX--
  49. XXron@vsedev.UUCP           (Ron Flax)
  50. XXUUCP:    ..!seismo!vsedev!ron
  51. XXARPA:    vsedev!ron@seismo.CSS.GOV
  52.  
  53. XX[ MODERATOR'S NOTE:  The /lib/cpp on my 4.2BSD Vax750 couldn't deal
  54. XX  with the long #define for HELP in the source; I added code to
  55. XX  #ifdef it out, but note that the Makefile by default enables it.
  56. XX  If get a "token too long" error, that's probably the cause.  -r$ ]
  57. @//E*O*F README//
  58. chmod u=rw,g=rw,o=rw README
  59.  
  60. echo x - laser.1
  61. if test -f laser.1 ; then
  62.     echo laser.1 exists, putting output in $$laser.1
  63.     OUT=$$laser.1
  64. else
  65.     OUT=laser.1
  66. fi
  67. sed 's/^XX//' > $OUT <<'@//E*O*F laser.1//'
  68. XX.TH LASER 1 
  69. XX.SH NAME
  70. XXlaser \- laser printer preprocessor
  71. XX.SH SYNTAX
  72. XX.B laser
  73. XX[ -{options} ]
  74. XX[ file ] ...
  75. XX.SH DESCRIPTION
  76. XX.I Laser
  77. XXcauses the
  78. XX.I files
  79. XXto be queued for printing on the laser printer.  If no files are named, the
  80. XXstandard input is read.  Actually 
  81. XX.I Laser
  82. XXreally only prepends the proper codes to set up the printer then
  83. XXfeeds the output to the system line printer spooler 
  84. XXfor further processing and spooling.
  85. XX.TP
  86. XXLaser Command Options:
  87. XX.TP
  88. XX.B c num
  89. XXCharacter Set where num is in the range of 1 to 18.  The numbers have
  90. XXthe following meanings:
  91. XX.DS L
  92. XX 1   Roman-8          2   USASCII         3   Roman Ext
  93. XX 4   Danish/Norwegian 5   United Kingdom  6   French
  94. XX 7   German           8   Italian         9   Swedish
  95. XX 10  Spanish          11  Legal           12  Linedraw
  96. XX 13  Math8            14  Math8a          15  Math8b
  97. XX 16  Math7            17  PiFont          18  PiFonta
  98. XX.DE
  99. XX.TP
  100. XX.B o [ P or L ]
  101. XXOrientation, portrait or landscape.
  102. XX.TP
  103. XX.B t num
  104. XXTypeface selection should be between the range of 1 to 10.  The numbers
  105. XXhave the following meanings:
  106. XX.DS L
  107. XX 1   Courier          2   Line Printer   3   Helvetica
  108. XX 4   Times Roman      5   Prestige Elite 6   Gothic
  109. XX 7   Pica             8   Script         9   Caslon
  110. XX 10  Orator
  111. XX.DE
  112. XX.TP
  113. XX.B h num
  114. XXPoint size which can be selected with a number between 1 and 6.  The
  115. XXnumbers have the following meanings:
  116. XX.DS L
  117. XX 1   7 Pt.            2   8 Pt.         3   8.5 Pt.
  118. XX 4   10 Pt.           5   12 Pt.        6   14.4 Pt.
  119. XX.DE
  120. XX.TP
  121. XX.B p num
  122. XXPitch selection can be either 1) 10cpi 2) 12cpi, or 3) 16.66cpi.
  123. XX.TP
  124. XX.B s [ P or L ]
  125. XXSpacing, proportional or fixed.
  126. XX.TP
  127. XX.B l num
  128. XXLines per inch, valid values are 1, 2, 3, 4, 6, 8, 12, 16, 24, etc.
  129. XX.TP
  130. XX.B i
  131. XXItalic, turns on italic mode for entire document.
  132. XX.TP
  133. XX.B b
  134. XXBold, turns on bold mode for entire document.
  135. XX.TP
  136. XX.B O num
  137. XXOffset from column zero.  Values can be any positive integer less than
  138. XXeighty.
  139. XX.TP
  140. XX.B P num
  141. XXPagestep, this is the number of lines that are needed to force the
  142. XXprinter to handle standard size sheets of paper.  This option is
  143. XXhardwired in at eight lines.  The option is provided so that you can
  144. XXdisable this feature.
  145. XX.TP
  146. XX.B F num
  147. XXForms length, this is the size (number of lines) of the paper. Default
  148. XXvalues for both portrait and landscape sheets are 66 and 54
  149. XXrespectfully.
  150. XX.TP
  151. XX.B w
  152. XXTells 
  153. XX.I laser
  154. XXto send the output to the standard output so that it can be piped to
  155. XXanother process or directed to another device.
  156. XX.PP
  157. XXIt is also possible and probably advisable to simply select a 
  158. XX.I typeface
  159. XXand maybe a left margin
  160. XX.I offset
  161. XXvalue and let the rest of the options run at their default values for
  162. XXthe typeface selected.
  163. XX.SH SEE ALSO
  164. XXlpr(1),
  165. XXlp(1),
  166. XXHewlet-Packard Technical Reference Guide
  167. XX.SH "AUTHOR"
  168. XXRon Flax
  169. @//E*O*F laser.1//
  170. chmod u=rw,g=rw,o=rw laser.1
  171.  
  172. echo x - laser.c
  173. if test -f laser.c ; then
  174.     echo laser.c exists, putting output in $$laser.c
  175.     OUT=$$laser.c
  176. else
  177.     OUT=laser.c
  178. fi
  179. sed 's/^XX//' > $OUT <<'@//E*O*F laser.c//'
  180. XX/*
  181. XX *            L A S E R . C 
  182. XX *
  183. XX * $Revision: 1.5 $
  184. XX *
  185. XX * $Log:    laser.c,v $
  186. XX * Revision 1.5  86/07/14  17:51:09  ron
  187. XX * Prepared for distribution
  188. XX * 
  189. XX * Revision 1.4  86/07/14  16:34:19  ron
  190. XX * Cleaned up code, generally made more human readable.
  191. XX * 
  192. XX * Revision 1.3  86/07/14  15:05:31  ron
  193. XX * Basically re-wrote the whole damned thing to support all, well most
  194. XX * of the LaserJet features that are available.  Instead of simply supporting
  195. XX * those that were originally used.  The program now supports all of the
  196. XX * HP font cartridges with most of the attributes available...
  197. XX * 
  198. XX * Revision 1.2  86/07/14  09:46:30  ron
  199. XX * Added distinctive RCS header
  200. XX * 
  201. XX */
  202. XX#ifndef lint
  203. XXstatic char RCSid[] = "@(#)$Header: laser.c,v 1.5 86/07/14 17:51:09 ron Exp $";
  204. XX#endif
  205.  
  206. XX#include <stdio.h>
  207.  
  208.  
  209. XX#define    LPRCMD "/usr/bin/lp 2>/dev/null 2>&1"
  210.  
  211. XX/*  If your system can handle it... */
  212. XX/* #define BIGHELPTEXT        /* ... mine can't */
  213.  
  214. XX#ifndef    BIGHELPTEXT
  215. XX#define HELP() fprintf (stderr, "Please read the manpage.\n");
  216. XX#define USAGE() fprintf (stderr, "Please read the manpage.\n");
  217.  
  218. XX#else
  219. XX#define USAGE() fprintf (stderr, \
  220. XX    ">>>> Type 'laser -H' to display a help screen.\n")
  221. XX#define HELP()    fprintf (stderr, \
  222. XX"Laser Command Options:\n\
  223. XX  c    --    Character Set\n\
  224. XX    (1)  Roman-8        (2)  USASCII  (3)  Roman Ext. (4)  Danish/Norwegian\n\
  225. XX    (5)  United Kingdom (6)  French   (7)  German     (8)  Italian\n\
  226. XX    (9)  Swedish       (10)  Spanish (11)  Legal     (12)  Linedraw\n\
  227. XX   (13)  Math8         (14)  Math8a  (15)  Math8b    (16)  Math7\n\
  228. XX   (17)  PiFont        (18)  PiFonta\n\
  229. XX  o    --    Orientation (Portrait or Landscape, P or L)\n\
  230. XX  t    --    Typeface\n\
  231. XX    (1)  Courier        (2)  Line Printer   (3)  Helvetica\n\
  232. XX    (4)  Times Roman    (5)  Prestige Elite (6)  Gothic\n\
  233. XX  h    --    Point Size (character height)\n\
  234. XX    (1)  7 Pt. (2)  8 Pt. (3)  8.5 Pt. (4)  10 Pt. (5)  12 Pt. (6)  14.4 Pt.\n\
  235. XX  p    --    Pitch\n\
  236. XX    (1)  10 cpi (2)  12 cpi (3)  16.66 cpi\n\
  237. XX  s    --    Spacing (Proportional or Fixed, P or F)\n\
  238. XX  l    --    Lines per inch (1, 2, 3, 4, 6, 8, 12, 16, 24)\n\
  239. XX  i    --    Italic\n\
  240. XX  b    --    Bold\n\
  241. XX  O    --    Offset from left edge (number of spaces)\n\
  242. XX  P    --    Page Step (number of extra lines)\n\
  243. XX  F    --    Forms Length (number of lines in form)\n\
  244. XX  w    --    Send results to standard output\n")
  245. XX#endif
  246.  
  247. XXstatic char *Symbols[] = 
  248. XX{
  249. XX    "\033(8U",     /* Roman-8 */
  250. XX    "\033(0U",    /* USASCII */
  251. XX        "\033(0E",    /* Roman Ext. */
  252. XX    "\033(0D",    /* Danish/Norwegian */
  253. XX    "\033(1E",    /* United Kingdom */
  254. XX    "\033(0F",    /* French */
  255. XX    "\033(0G",    /* German */
  256. XX    "\033(0I",    /* Italian */
  257. XX    "\033(0S",    /* Swedish/Finnish */
  258. XX    "\033(1S",    /* Spanish */
  259. XX    "\033(1U",    /* Legal */
  260. XX    "\033(0B",    /* Line Draw */
  261. XX    "\033(8M",    /* Math8 */
  262. XX    "\033(0Q",    /* Math8a */
  263. XX    "\033(1Q",    /* Math8b */
  264. XX    "\033(0M",    /* Math7 */
  265. XX    "\033(15U",    /* PiFont */
  266. XX    "\033(2Q",    /* PiFonta */
  267. XX    0
  268. XX};
  269.  
  270. XXstatic char *Spacing[] = 
  271. XX{
  272. XX    "\033(s1P",    /* Proportional */
  273. XX    "\033(s0P",    /* Fixed */
  274. XX    0
  275. XX};
  276.  
  277. XXstatic char *Type[] =
  278. XX{            /* Yes I know their not in order... */
  279. XX    "\033(s3T",    /* Courier (default) */
  280. XX    "\033(s0T",    /* Line Printer */
  281. XX    "\033(s4T",    /* Helvetica */
  282. XX    "\033(s5T",     /* Times Roman */
  283. XX    "\033(s8T",     /* Prestige Elite */
  284. XX    "\033(s6T",     /* Gothic */
  285. XX    "\033(s1T",    /* Pica */
  286. XX    "\033(s7T",    /* Script */
  287. XX    "\033(s9T",    /* Caslon */
  288. XX    "\033(s10T",    /* Orator */
  289. XX    0
  290. XX};
  291.  
  292. XXstatic char *Orientation[] = 
  293. XX{
  294. XX    "\033&l0O",     /* Portrait */
  295. XX    "\033&l1O",    /* Landscape */
  296. XX    0
  297. XX};
  298.  
  299. XXstatic char *Point[] = 
  300. XX{
  301. XX    "\033(s7V",    /* 7 Pt. */
  302. XX    "\033(s8V",    /* 8 Pt. */
  303. XX    "\033(s8.5V",    /* 8.5 Pt. */
  304. XX    "\033(s10V",     /* 10 Pt. */
  305. XX    "\033(s12V",    /* 12 Pt. */
  306. XX    "\033(s14.4V",    /* 14.4 Pt */
  307. XX    0
  308. XX};
  309.  
  310. XXstatic char *Pitch[] =
  311. XX{
  312. XX    "\033(s10H",    /* 10 CPI */
  313. XX    "\033(s12H",    /* 12 CPI */
  314. XX    "\033(s16.6H",    /* 16.66 CPI */
  315. XX    "",        /* no pitch for proportional spacing */
  316. XX    0
  317. XX};
  318.  
  319. XXstatic char *Lpi[] = 
  320. XX{
  321. XX    "\033&l7.27c66F", /* 66 lines per page with 1/2 at top and bot */
  322. XX    "\033&l1d66F",    /* 1 lpi */
  323. XX    "\033&l2d66F",    /* 2 lpi */
  324. XX    "\033&l3d66F",    /* 3 lpi */
  325. XX    "\033&l4d66F",    /* 4 lpi */
  326. XX    "\033&l6d66F",    /* 6 lpi */
  327. XX    "\033&l8d66F",    /* 8 lpi */
  328. XX    "\033&l12d66F",   /* 12 lpi */
  329. XX    "\033&l16d66F",   /* 16 lpi */
  330. XX    "\033&l24d66F",   /* 24 lpi */
  331. XX    0
  332. XX};
  333.  
  334. XXstatic char *Italic = "\033(s1S";
  335.  
  336. XXstatic char *Bold   = "\033(s3B";
  337.  
  338. XX#define        CTRL(c)        ('c' & 037)
  339.  
  340. XX/*
  341. XX *  Defaults
  342. XX */
  343.  
  344. XXint    sym = 1;
  345. XXint    type = 0;
  346. XXint    spc = 1;
  347. XXint    orient = 0;
  348. XXint    ps = 3;
  349. XXint    ptch = 0;
  350. XXint    lpi = 0;
  351. XXint    offset = 0;
  352. XXint    stdoutput = 0;
  353. XXint    pagestep = 8;
  354. XXint    forms = 66;
  355. XXint    italic = 0;
  356. XXint    bold = 0;
  357. XXint    Debug = 0;
  358.  
  359. XXmain (argc, argv)
  360. XX    int argc;
  361. XX    char *argv[];
  362. XX{
  363. XX    FILE           *fp, *fopen();
  364. XX    extern char    *optarg;
  365. XX    extern int      optind;
  366. XX    int             i, c, errflg = 0;
  367.  
  368. XX    while ((c = getopt(argc, argv, "c:o:t:h:l:s:p:O:P:F:biHwd")) != EOF) {
  369. XX        switch (c) {
  370. XX        case 'd':
  371. XX            ++Debug;
  372. XX            break;
  373.  
  374. XX        case 'l':
  375. XX            lpi = atoi(optarg);
  376. XX            switch (lpi) {
  377. XX            case 1: case 2: case 3: case 4: case 6:
  378. XX            case 8: case 12: case 16: case 24:
  379. XX                if (Debug)
  380. XX                    fprintf(stderr, "lpi = %d, ", lpi);
  381. XX                break;
  382. XX            default:
  383. XX                printf("Lines Per Inch values must be one of 1, 2, 3, 4, 6, 8, 12, 16, or 24.\n");
  384. XX                USAGE();
  385. XX                exit(1);
  386. XX            }
  387. XX            break;
  388. XX        case 'o':
  389. XX            if (*optarg == 'p' || *optarg == 'P')
  390. XX                orient = 0;
  391. XX            else if (*optarg == 'l' || *optarg == 'L')
  392. XX                orient = 1;
  393. XX            else {
  394. XX                printf("Orientation must be specified as either 'P' or 'L'.\n");
  395. XX                USAGE();
  396. XX                exit(1);
  397. XX            }
  398. XX            if (Debug)
  399. XX                fprintf (stderr,"orientation -> %c, ", *optarg);
  400. XX            break;
  401.  
  402. XX        case 't':
  403. XX            type = atoi(optarg);
  404. XX            --type;
  405. XX            if (type < 0 || type > 10) {
  406. XX                printf("Typeface selection must be in the range of 1 (one) to 6 (six).\n");
  407. XX                USAGE();
  408. XX                exit(1);
  409. XX            }
  410. XX            /* Set up some defaults in case none of these are
  411. XX               chosen explicitly */
  412. XX            switch (type) {
  413. XX            case 0:
  414. XX                sym = orient = ptch = 0; spc = 1; ps = 4;
  415. XX                break;
  416. XX            case 1:
  417. XX                sym = spc = 1; orient = 0; ps = ptch = 2;
  418. XX                break;
  419. XX            case 2:
  420. XX                sym = spc = 0; orient = 1; ps = ptch = 3;
  421. XX                break;
  422. XX            case 3:
  423. XX                sym = spc = orient = 0; ps = 4; ptch = 1;
  424. XX                break;
  425. XX            case 4:
  426. XX                sym = orient = 0; spc = 1; ps = 3; ptch = 1;
  427. XX                break;
  428. XX            case 5:
  429. XX                sym = orient = 0; spc = 1; ps = 4; ptch = 1;
  430. XX                break;
  431. XX            case 6:
  432. XX                sym = orient = 0; spc = ptch = 1; ps = 4;
  433. XX                break;
  434. XX            }
  435. XX            if (Debug)
  436. XX                fprintf (stderr, "typeface = %d, ", type);
  437. XX            break;
  438.  
  439. XX        case 's':
  440. XX            if (*optarg == 'P' || *optarg == 'p') {
  441. XX                spc = 0;
  442. XX                ptch = 3;
  443. XX            }
  444. XX            else if (*optarg == 'F' || *optarg == 'f')
  445. XX                spc = 1;
  446. XX            else {
  447. XX                printf("Spacing must be specified as either 'P' or 'F'\n");
  448. XX                USAGE();
  449. XX                exit(1);
  450. XX            }
  451. XX            if (Debug)
  452. XX                fprintf (stderr, "spacing -> %c, ", *optarg);
  453. XX            break;
  454.  
  455. XX        case 'h':
  456. XX            ps = atoi(optarg);
  457. XX            --ps;
  458. XX            if (ps < 0 || ps > 6) {
  459. XX                printf("Point size must be specified within the range of 1 (one) to 6 (six)\n");
  460. XX                USAGE();
  461. XX                exit(1);
  462. XX            }
  463. XX            if (Debug)
  464. XX                fprintf (stderr, "point size = %d, ", ps);
  465. XX            break;
  466.  
  467. XX        case 'p':
  468. XX            ptch = atoi(optarg);
  469. XX            --ptch;
  470. XX            if (ptch < 0 || ptch > 3) {
  471. XX                printf("Pitch must be specified within the range of 1 (one) to 6 (six).\n");
  472. XX                USAGE();
  473. XX                exit(1);
  474. XX            }
  475. XX            if (Debug)
  476. XX                fprintf (stderr, "pitch = %d, ", ptch);
  477. XX            break;
  478.  
  479. XX        case 'c':    /* Symbol Set selection */
  480. XX            sym = atoi(optarg);
  481. XX            --sym;
  482. XX            if (sym < 0 || sym > 18) {
  483. XX                printf("Character set selection must be between the range of 1 (one) and 18 (eighteen).\n");
  484. XX                USAGE();
  485. XX                exit(1);
  486. XX            }
  487. XX            if (Debug)
  488. XX                fprintf(stderr, "symbol set = %d, ", sym);
  489. XX            break;
  490.  
  491. XX        case 'O':    /* Offset from left margin */
  492. XX            offset = atoi(optarg);
  493. XX            if (offset < 0 || offset > 80) {
  494. XX                printf("Offset value must be specified between the range of 0 (zero) and 80 (eighty).\n");
  495. XX                USAGE();
  496. XX                exit(1);
  497. XX            }
  498. XX            if (Debug)
  499. XX                fprintf(stderr, "offset = %d, ", offset);
  500. XX            break;
  501.  
  502. XX        case 'P':
  503. XX            pagestep = atoi(optarg);
  504. XX            if (pagestep < 0 || pagestep > 66) {
  505. XX                printf("Page Step value must be specified between the range of 1 (one) and 66 (sixty six).\n");
  506. XX                USAGE();
  507. XX                exit(1);
  508. XX            }
  509. XX            if (Debug)
  510. XX                fprintf (stderr, "page step = %d, ", pagestep);
  511. XX            break;
  512.  
  513. XX        case 'F':
  514. XX            forms = atoi(optarg);
  515. XX            if (forms < 0) {
  516. XX                printf("Forms value must be greater than 0 (zero).\n");
  517. XX                USAGE();
  518. XX                exit(1);
  519. XX            }
  520. XX            if (Debug)
  521. XX                fprintf (stderr, "forms = %d, ", forms);
  522. XX            break;
  523.  
  524. XX        case 'i':
  525. XX            italic++;
  526. XX            if (Debug)
  527. XX                fprintf (stderr, "italics set, ");
  528. XX            break;
  529.  
  530. XX        case 'b':
  531. XX            bold++;
  532. XX            if (Debug)
  533. XX                fprintf (stderr, "bold set, ");
  534. XX            break;
  535.  
  536. XX        case 'w':    /* Standard Output */
  537. XX            if (Debug)
  538. XX                fprintf (stderr, "results to stdout, ");
  539. XX            stdoutput++;
  540. XX            break;
  541.  
  542. XX        case 'H':
  543. XX            HELP();
  544. XX            exit (1);
  545.  
  546. XX        default:
  547. XX            errflg++;
  548. XX            break;
  549. XX        }
  550. XX    }
  551.  
  552. XX    if (errflg) {
  553. XX        fprintf (stderr, "laser [ - {options} ] [ files ] ... \n");
  554. XX        USAGE();
  555. XX        exit(1);
  556. XX    }
  557.  
  558. XX    if (Debug) fprintf (stderr, "\b \n");
  559.  
  560. XX    if (argc == optind)
  561. XX        sendjob(stdin);
  562. XX    else
  563. XX        for (; optind < argc; optind++)
  564. XX            if ((fp = fopen(argv[optind], "r")) == NULL) {
  565. XX                fprintf(stderr, "laser: can't open %s\n", argv[optind]);
  566. XX                exit(1);
  567. XX            } else {
  568. XX                sendjob(fp);
  569. XX                fclose(fp);
  570. XX            }
  571. XX    exit(0);
  572. XX}
  573.  
  574. XXsendjob (fp)
  575. XX    FILE *fp;
  576. XX{
  577. XX    FILE    *pp, *popen();
  578. XX    int pg = pagestep, c, lines;
  579.  
  580. XX    if (! stdoutput) {
  581. XX        if ((pp = popen (LPRCMD, "w")) == NULL) {
  582. XX        fprintf(stderr,"laser: cannot pipe to line printer device.\n");
  583. XX        exit (1);
  584. XX        }
  585. XX    } else 
  586. XX        pp = stdout;
  587.  
  588. XX            /* reset        perf skip ON */
  589. XX    fprintf (pp, "\033E%s%s%s%s%s%s%s\033&l1L\r",
  590. XX        Symbols[sym],
  591. XX        Spacing[spc], 
  592. XX        Orientation[orient],
  593. XX        Type[type],
  594. XX        Point[ps],
  595. XX        Lpi[lpi], 
  596. XX        Pitch[ptch]);
  597.  
  598. XX    if (forms != 66)
  599. XX        fprintf (pp, "\033&l%dF\r", forms);
  600.  
  601. XX    if (bold)
  602. XX        fprintf (pp, "%s\r", Bold);
  603.  
  604. XX    if (italic)
  605. XX        fprintf (pp, "%s\r", Italic);
  606.  
  607. XX    if (offset)
  608. XX        fprintf (pp, "\033&a%dL\r", offset);
  609.  
  610. XX    while ((c = getc (fp)) != EOF) {
  611. XX        if (c == CTRL(l)) {
  612. XX            while (lines < forms) {
  613. XX                putc ('\n', pp);
  614. XX                lines++;
  615. XX                }
  616. XX            continue;    /* eat the ^L char */
  617. XX        }
  618. XX        if (c == CTRL(j)) {
  619. XX            if (lines == forms) {
  620. XX                while (pg-- > 0)
  621. XX                    putc ('\n', pp);
  622. XX                lines = 0;
  623. XX                continue;
  624. XX            } else
  625. XX                lines++;
  626. XX        }
  627. XX        putc (c, pp);
  628. XX    }
  629. XX    fprintf (pp, "\033E"); /* reset the printer to default settings */
  630. XX    pclose (pp);
  631. XX}
  632. @//E*O*F laser.c//
  633. chmod u=rw,g=rw,o=rw laser.c
  634.  
  635. echo x - Makefile
  636. if test -f Makefile ; then
  637.     echo Makefile exists, putting output in $$Makefile
  638.     OUT=$$Makefile
  639. else
  640.     OUT=Makefile
  641. fi
  642. sed 's/^XX//' > $OUT <<'@//E*O*F Makefile//'
  643. XX# Where is getopt on your system?
  644. XXGETOPT    = -lgetopt
  645.  
  646. XX# If you get errors, comment out the next line.
  647. XXDEFS    = -DBIGHELPTEXT
  648.  
  649. XXCFLAGS    = -O $(DEFS)
  650.  
  651. XXlaser:    laser.c
  652. XX    cc $(CFLAGS) -o laser laser.c $(GETOPT)
  653. @//E*O*F Makefile//
  654. chmod u=rw,g=rw,o=rw Makefile
  655.  
  656. echo Inspecting for damage in transit...
  657. temp=/tmp/sharin$$; dtemp=/tmp/sharout$$
  658. trap "rm -f $temp $dtemp; exit" 0 1 2 3 15
  659. cat > $temp <<\!!!
  660.       31     263    1528 README
  661.      101     486    2729 laser.1
  662.      452    1628   10042 laser.c
  663.       10      35     200 Makefile
  664.      594    2412   14499 total
  665. !!!
  666. wc  README laser.1 laser.c Makefile | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp
  667. if test -s $dtemp
  668. then echo "Ouch [diff of wc output]:" ; cat $dtemp
  669. else echo "No problems found."
  670. fi
  671. exit 0
  672.